package com.dries.chat.controller;

import com.dries.chat.form.JoinChatRoomForm;
import com.dries.chat.service.IRoomService;
import com.dries.chat.service.IRoomUserService;
import com.dries.common.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 聊天室用户表
 *
 * @author dries
 * @email samphsanie@gmail.com
 * @date 2020-07-24 10:13:58
 */
@Api(tags = "聊天室成员管理API", value = "RoomUserController")
@RestController
@RequestMapping("/chat/user")
public class RoomUserController {

    @Resource
    private IRoomUserService roomUserService;
    @Resource
    private IRoomService roomService;

    /**
     * 保存
     */
    @ApiOperation("加入聊天室")
    @PostMapping("/join")
    public CommonResult join(@Valid @RequestBody JoinChatRoomForm form){

        int result = roomService.joinChat(form);
        if (result == 1) {
            return CommonResult.success("加入聊天室成功！");
        } else {
            return CommonResult.failed("加入聊天室失败！");
        }

    }

//    /**
//     * 列表
//     */
//    @GetMapping("/list")
//    public R list(@RequestParam Map<String, Object> params){
//        PageUtils page = roomUserService.queryPage(params);
//
//        return R.ok().put("page", page);
//    }
//
//
//    /**
//     * 信息
//     */
//    @GetMapping("/info/{id}")
//    public R info(@PathVariable("id") Long id){
//		RoomUser roomUser = roomUserService.getById(id);
//
//        return R.ok().put("roomUser", roomUser);
//    }
//
//    /**
//     * 保存
//     */
//    @PostMapping("/save")
//    public R save(@RequestBody RoomUser roomUser){
//		roomUserService.save(roomUser);
//
//        return R.ok();
//    }
//
//    /**
//     * 修改
//     */
//    @PutMapping("/update")
//    public R update(@RequestBody RoomUser roomUser){
//		roomUserService.updateById(roomUser);
//
//        return R.ok();
//    }
//
//    /**
//     * 删除
//     */
//    @DeleteMapping("/delete")
//    public R delete(@RequestBody Long[] ids){
//		roomUserService.removeByIds(Arrays.asList(ids));
//
//        return R.ok();
//    }

}
